package com.zhentao.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.Date;

/**
 * 查询条件模板表：存储用户查询模板，支撑模板保存与复用功能
 * @TableName t_query_template
 */
@TableName(value ="t_query_template")
@Data
public class TQueryTemplate {
    /**
     * 主键（自增）
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 模板名称（如“北京关区8月A类企业进口查询”，用户自定义）
     */
    private String templateName;

    /**
     * 查询类型（枚举：汇总查询/数据查询/原始数据查询，区分模板适用模块）
     */
    private String queryType;

    /**
     * 模板创建人账号（如“admin01”，支撑个人模板权限）
     */
    private String userAccount;

    /**
     * 关联关区代码（如0100=北京关区，模板仅在对应关区可见）
     */
    private String customsCode;

    /**
     * 模板中的进出口类型（可空=不限制，存储模板筛选条件）
     */
    private String importExportType;

    /**
     * 模板中的结关开始日期（存储模板时间范围）
     */
    private Date customsClearanceStartDate;

    /**
     * 模板中的结关结束日期（存储模板时间范围）
     */
    private Date customsClearanceEndDate;

    /**
     * 一级分组维度（如“declare_customs=关区”，仅汇总查询用，最多3级）
     */
    private String groupDimension1;

    /**
     * 二级分组维度（仅汇总查询用）
     */
    private String groupDimension2;

    /**
     * 三级分组维度（仅汇总查询用，满足“最多选三个分组维度”需求）
     */
    private String groupDimension3;

    /**
     * 输出字段列表（如“declare_amount,declare_count”，用逗号分隔，存储模板输出配置）
     */
    private String outputFields;

    /**
     * 筛选条件（JSON格式存储，如{"enterprise_credit_level":"A","hs_code":"01%"}，存储模板筛选规则）
     */
    private String filterConditions;

    /**
     * 模板创建时间
     */
    private Date createTime;

    /**
     * 模板更新时间
     */
    private Date updateTime;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        TQueryTemplate other = (TQueryTemplate) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getTemplateName() == null ? other.getTemplateName() == null : this.getTemplateName().equals(other.getTemplateName()))
            && (this.getQueryType() == null ? other.getQueryType() == null : this.getQueryType().equals(other.getQueryType()))
            && (this.getUserAccount() == null ? other.getUserAccount() == null : this.getUserAccount().equals(other.getUserAccount()))
            && (this.getCustomsCode() == null ? other.getCustomsCode() == null : this.getCustomsCode().equals(other.getCustomsCode()))
            && (this.getImportExportType() == null ? other.getImportExportType() == null : this.getImportExportType().equals(other.getImportExportType()))
            && (this.getCustomsClearanceStartDate() == null ? other.getCustomsClearanceStartDate() == null : this.getCustomsClearanceStartDate().equals(other.getCustomsClearanceStartDate()))
            && (this.getCustomsClearanceEndDate() == null ? other.getCustomsClearanceEndDate() == null : this.getCustomsClearanceEndDate().equals(other.getCustomsClearanceEndDate()))
            && (this.getGroupDimension1() == null ? other.getGroupDimension1() == null : this.getGroupDimension1().equals(other.getGroupDimension1()))
            && (this.getGroupDimension2() == null ? other.getGroupDimension2() == null : this.getGroupDimension2().equals(other.getGroupDimension2()))
            && (this.getGroupDimension3() == null ? other.getGroupDimension3() == null : this.getGroupDimension3().equals(other.getGroupDimension3()))
            && (this.getOutputFields() == null ? other.getOutputFields() == null : this.getOutputFields().equals(other.getOutputFields()))
            && (this.getFilterConditions() == null ? other.getFilterConditions() == null : this.getFilterConditions().equals(other.getFilterConditions()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getTemplateName() == null) ? 0 : getTemplateName().hashCode());
        result = prime * result + ((getQueryType() == null) ? 0 : getQueryType().hashCode());
        result = prime * result + ((getUserAccount() == null) ? 0 : getUserAccount().hashCode());
        result = prime * result + ((getCustomsCode() == null) ? 0 : getCustomsCode().hashCode());
        result = prime * result + ((getImportExportType() == null) ? 0 : getImportExportType().hashCode());
        result = prime * result + ((getCustomsClearanceStartDate() == null) ? 0 : getCustomsClearanceStartDate().hashCode());
        result = prime * result + ((getCustomsClearanceEndDate() == null) ? 0 : getCustomsClearanceEndDate().hashCode());
        result = prime * result + ((getGroupDimension1() == null) ? 0 : getGroupDimension1().hashCode());
        result = prime * result + ((getGroupDimension2() == null) ? 0 : getGroupDimension2().hashCode());
        result = prime * result + ((getGroupDimension3() == null) ? 0 : getGroupDimension3().hashCode());
        result = prime * result + ((getOutputFields() == null) ? 0 : getOutputFields().hashCode());
        result = prime * result + ((getFilterConditions() == null) ? 0 : getFilterConditions().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", templateName=").append(templateName);
        sb.append(", queryType=").append(queryType);
        sb.append(", userAccount=").append(userAccount);
        sb.append(", customsCode=").append(customsCode);
        sb.append(", importExportType=").append(importExportType);
        sb.append(", customsClearanceStartDate=").append(customsClearanceStartDate);
        sb.append(", customsClearanceEndDate=").append(customsClearanceEndDate);
        sb.append(", groupDimension1=").append(groupDimension1);
        sb.append(", groupDimension2=").append(groupDimension2);
        sb.append(", groupDimension3=").append(groupDimension3);
        sb.append(", outputFields=").append(outputFields);
        sb.append(", filterConditions=").append(filterConditions);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append("]");
        return sb.toString();
    }
}